import requset from './request';
import querystring from 'query-string';

/**------------------------------------   登录注册接口   ----------------------------------------- */

// 登录接口后端不支持传对象，需要转字符串
export const reqLogin = (userInfo) => requset({url: '/login', method: 'post', data: querystring.stringify(userInfo)})

export const updateUserInfo = (params) => requset({url: '/update/userInfo', method: 'get', params})

export const reqGetUserInfo = (params) => requset({url: '/getuserInfo', method: 'get', params})

/**-------------------------------------   商品列表接口   ----------------------------------------- */

export const reqGetGoodsList = () => requset({url: '/goodsList', method: 'get'})

/**-------------------------------------   地址接口   ----------------------------------------- */

export const reqGetAddress = (params) => requset({url: '/getuserInfo/address', method: 'get', params})

export const updateAddress = (params) => requset({url: '/getuserInfo/address/add', method: 'get', params})

/**-------------------------------------   商品列表接口   ----------------------------------------- */

export const reqGetCityInfo = () => requset({url: '/cityInfo', method: 'get'})

/**-------------------------------------   购物车接口   ----------------------------------------- */

export const reqAddShopCart = (params) => requset({url: '/shopCart/add', method: 'get', params})

export const reqGetShopCart = (params) => requset({url: '/getShopCart', method: 'get', params})

export const reqDelShopCart = (params) => requset({url: '/shopCart/del', method: 'get', params})

export const reqDelAllShopCart = (params) => requset({url: '/shopCart/delAll', method: 'get', params})

/**-------------------------------------   订单接口   ----------------------------------------- */

export const reqAddOrder = (params) => requset({url: '/addOrder', method: 'get', params})

export const reqgetOrder = (params) => requset({url: '/getOrder', method: 'get', params})

export const reqGetAllOrder = (params) => requset({url: '/getAllOrder', method: 'get', params})

export const reqDelOrder = (params) => requset({url: '/delOrder', method: 'get', params})

/**-------------------------------------  支付宝沙箱支付接口   ----------------------------------------- */

export const reqZfbPay = (orderObj) => requset({url: '/pay', method: 'post', data: querystring.stringify(orderObj)})

export const reqPaySuccess = (data) => requset({url: '/pay/orderStatu', method: 'post', data: querystring.stringify(data)})
